package cn.edu.scau.cmi.ChenKaihui.singleTon;

/**
 * 单例模式
 */
public class Chairman {
    // 创建类的惟一实例
    private static Chairman chairman;
    private String name;

    // 将构造函数私有化，不允许外部直接创建对象
    private Chairman(String name) {
        this.setName(name);
    }

    // 提供一个用于获取实例的公共方法
    public static Chairman getInstance() {
        if (chairman == null) {
            chairman = new Chairman("毛泽东");
        }
        return chairman;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

}
